home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / boot / czesc_2 / toolmanager / source / prefs / locale.c < prev    next >
C/C++ Source or Header  |  1993-05-15  |  5KB  |  185 lines

  1. /*
  2.  * locale.c  V2.1
  3.  *
  4.  * localization stuff
  5.  *
  6.  * (c) 1990-1993 Stefan Becker
  7.  */
  8.  
  9. #include "ToolManagerConf.h"
  10.  
  11. /* locale string array */
  12. char *AppStrings[]={
  13.     MSG_WINDOW_TOP_GAD_STR,
  14.     MSG_WINDOW_UP_GAD_STR,
  15.     MSG_WINDOW_DOWN_GAD_STR,
  16.     MSG_WINDOW_BOTTOM_GAD_STR,
  17.     MSG_WINDOW_REMOVE_GAD_STR,
  18.     MSG_WINDOW_NAME_GAD_STR,
  19.     MSG_WINDOW_COMMAND_GAD_STR,
  20.     MSG_WINDOW_HOTKEY_GAD_STR,
  21.     MSG_WINDOW_PUBSCREEN_GAD_STR,
  22.     MSG_WINDOW_POSITION_OPEN_LABEL_STR,
  23.     MSG_WINDOW_POSITION_CLOSE_LABEL_STR,
  24.     MSG_WINDOW_LEFTEDGE_GAD_STR,
  25.     MSG_WINDOW_TOPEDGE_GAD_STR,
  26.     MSG_WINDOW_EXEC_GAD_STR,
  27.     MSG_WINDOW_IMAGE_GAD_STR,
  28.     MSG_WINDOW_SOUND_GAD_STR,
  29.     MSG_WINDOW_OK_GAD_STR,
  30.     MSG_WINDOW_CANCEL_GAD_STR,
  31.  
  32.     MSG_MAINWIN_TITLE_STR,
  33.     MSG_MAINWIN_TYPE_GAD_STR,
  34.     MSG_MAINWIN_TYPE_EXEC_CYCLE_LABEL_STR,
  35.     MSG_MAINWIN_TYPE_IMAGE_CYCLE_LABEL_STR,
  36.     MSG_MAINWIN_TYPE_SOUND_CYCLE_LABEL_STR,
  37.     MSG_MAINWIN_TYPE_MENU_CYCLE_LABEL_STR,
  38.     MSG_MAINWIN_TYPE_ICON_CYCLE_LABEL_STR,
  39.     MSG_MAINWIN_TYPE_DOCK_CYCLE_LABEL_STR,
  40.     MSG_MAINWIN_TYPE_ACCESS_CYCLE_LABEL_STR,
  41.     MSG_MAINWIN_LIST_GAD_STR,
  42.     MSG_MAINWIN_SORT_GAD_STR,
  43.     MSG_MAINWIN_NEW_GAD_STR,
  44.     MSG_MAINWIN_EDIT_GAD_STR,
  45.     MSG_MAINWIN_COPY_GAD_STR,
  46.     MSG_MAINWIN_SAVE_GAD_STR,
  47.     MSG_MAINWIN_USE_GAD_STR,
  48.     MSG_MAINWIN_TEST_GAD_STR,
  49.  
  50.     MSG_MAINWIN_PROJECT_MENU_LABEL_STR,
  51.     MSG_MAINWIN_OPEN_MENU_LABEL_STR,
  52.     MSG_MAINWIN_OPEN_MENU_SHORTCUT_STR,
  53.     MSG_MAINWIN_APPEND_MENU_LABEL_STR,
  54.     MSG_MAINWIN_SAVEAS_MENU_LABEL_STR,
  55.     MSG_MAINWIN_SAVEAS_MENU_SHORTCUT_STR,
  56.     MSG_MAINWIN_ABOUT_MENU_LABEL_STR,
  57.     MSG_MAINWIN_QUIT_MENU_LABEL_STR,
  58.     MSG_MAINWIN_QUIT_MENU_SHORTCUT_STR,
  59.     MSG_MAINWIN_EDIT_MENU_LABEL_STR,
  60.     MSG_MAINWIN_LASTSAVED_MENU_LABEL_STR,
  61.     MSG_MAINWIN_LASTSAVED_MENU_SHORTCUT_STR,
  62.     MSG_MAINWIN_RESTORE_MENU_LABEL_STR,
  63.     MSG_MAINWIN_RESTORE_MENU_SHORTCUT_STR,
  64.     MSG_MAINWIN_SETTINGS_MENU_LABEL_STR,
  65.     MSG_MAINWIN_CREATEICONS_MENU_LABEL_STR,
  66.     MSG_MAINWIN_CREATEICONS_MENU_SHORTCUT_STR,
  67.  
  68.     MSG_MAINWIN_WRITE_ERROR_STR,
  69.  
  70.     MSG_EXECWIN_TITLE_STR,
  71.     MSG_EXECWIN_NEWNAME_STR,
  72.     MSG_EXECWIN_EXECTYPE_GAD_STR,
  73.     MSG_EXECWIN_CURRENTDIR_GAD_STR,
  74.     MSG_EXECWIN_OUTPUT_GAD_STR,
  75.     MSG_EXECWIN_PATH_GAD_STR,
  76.     MSG_EXECWIN_STACK_GAD_STR,
  77.     MSG_EXECWIN_PRIORITY_GAD_STR,
  78.     MSG_EXECWIN_DELAY_GAD_STR,
  79.     MSG_EXECWIN_ARGUMENTS_GAD_STR,
  80.     MSG_EXECWIN_TOFRONT_GAD_STR,
  81.  
  82.     MSG_IMAGEWIN_TITLE_STR,
  83.     MSG_IMAGEWIN_NEWNAME_STR,
  84.     MSG_IMAGEWIN_FILE_GAD_STR,
  85.  
  86.     MSG_SOUNDWIN_TITLE_STR,
  87.     MSG_SOUNDWIN_NEWNAME_STR,
  88.     MSG_SOUNDWIN_AREXX_GAD_STR,
  89.  
  90.     MSG_MENUWIN_TITLE_STR,
  91.     MSG_MENUWIN_NEWNAME_STR,
  92.  
  93.     MSG_ICONWIN_TITLE_STR,
  94.     MSG_ICONWIN_NEWNAME_STR,
  95.     MSG_ICONWIN_SHOWNAME_GAD_STR,
  96.  
  97.     MSG_DOCKWIN_TITLE_STR,
  98.     MSG_DOCKWIN_NEWNAME_STR,
  99.     MSG_DOCKWIN_TITLE_GAD_STR,
  100.     MSG_DOCKWIN_COLUMNS_GAD_STR,
  101.     MSG_DOCKWIN_FONT_GAD_STR,
  102.     MSG_DOCKWIN_ACTIVATED_GAD_STR,
  103.     MSG_DOCKWIN_BACKDROP_GAD_STR,
  104.     MSG_DOCKWIN_CENTERED_GAD_STR,
  105.     MSG_DOCKWIN_FRONTMOST_GAD_STR,
  106.     MSG_DOCKWIN_MENU_GAD_STR,
  107.     MSG_DOCKWIN_PATTERN_GAD_STR,
  108.     MSG_DOCKWIN_POPUP_GAD_STR,
  109.     MSG_DOCKWIN_STICKY_GAD_STR,
  110.     MSG_DOCKWIN_TEXT_GAD_STR,
  111.     MSG_DOCKWIN_VERTICAL_GAD_STR,
  112.     MSG_DOCKWIN_EDITTOOLS_GAD_STR,
  113.  
  114.     MSG_DOCKLISTWIN_TITLE_STR,
  115.     MSG_DOCKLISTWIN_TOOLS_GAD_STR,
  116.     MSG_DOCKLISTWIN_NEW_GAD_STR,
  117.  
  118.     MSG_ACCESSWIN_TITLE_STR,
  119.     MSG_ACCESSWIN_NEWNAME_STR,
  120.     MSG_ACCESSWIN_ENTRIES_GAD_STR,
  121.     MSG_ACCESSWIN_ADD_GAD_STR,
  122.  
  123.     MSG_SELECTWIN_TITLE_STR,
  124.     MSG_SELECTWIN_OBJECT_GAD_STR,
  125.     MSG_SELECTWIN_MENU_MX_LABEL_STR,
  126.     MSG_SELECTWIN_ICON_MX_LABEL_STR,
  127.     MSG_SELECTWIN_MENUICON_MX_LABEL_STR,
  128.  
  129.     MSG_MOVEWIN_DRAG_GAD_STR,
  130.  
  131.     MSG_FILEREQ_TITLE_FILE_STR,
  132.     MSG_FILEREQ_TITLE_DRAWER_STR,
  133.     MSG_FILEREQ_OK_GAD_STR,
  134.     MSG_FILEREQ_SAVE_GAD_STR,
  135.     MSG_FILEREQ_CANCEL_GAD_STR,
  136.  
  137.     MSG_FONTREQ_TITLE_STR,
  138.  
  139.     MSG_LISTREQ_TITLE_EXEC_STR,
  140.     MSG_LISTREQ_TITLE_IMAGE_STR,
  141.     MSG_LISTREQ_TITLE_SOUND_STR,
  142.     MSG_LISTREQ_TITLE_DOCK_STR,
  143.     MSG_LISTREQ_TITLE_PUBSCREEN_STR,
  144.  
  145.     MSG_HOSTREQ_TITLE_STR
  146. };
  147.  
  148. /* misc. data */
  149. struct Library *LocaleBase=NULL;
  150. static struct Catalog *Catalog;
  151.  
  152. /* Get locale strings */
  153. void GetLocale(void)
  154. {
  155.  /* Try to open locale.library */
  156.  if (LocaleBase=OpenLibrary("locale.library",38)) {
  157.  
  158.   DEBUG_PRINTF("Locale: 0x%08lx\n",LocaleBase);
  159.  
  160.   /* Try to get catalog for current language */
  161.   if (Catalog=OpenCatalog(NULL,"toolmanager.catalog",
  162.                           OC_BuiltInLanguage, "english",
  163.                           OC_Version,         3,
  164.                           TAG_DONE)) {
  165.    /* Read in locale language strings */
  166.    char **as=AppStrings;
  167.    ULONG i;
  168.  
  169.    DEBUG_PRINTF("Catalog: 0x%08lx\n",Catalog);
  170.  
  171.    /* Get translation strings */
  172.    for (i=0; i<=MSG_HOSTREQ_TITLE; i++, as++)
  173.     *as=GetCatalogStr(Catalog,i,*as);
  174.   }
  175.  }
  176. }
  177.  
  178. void FreeLocale(void)
  179. {
  180.  if (LocaleBase) {
  181.   if (Catalog) CloseCatalog(Catalog);
  182.   CloseLibrary(LocaleBase);
  183.  }
  184. }
  185.